<?php

namespace App\Http\Controllers\Screen;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

/**
 * 公用类
 */
class CommonController extends Controller
{
    public $request = null;
    public function __construct(Request $request)
    {
        $this->request = $request;
    }


    /**
     * 返回api设置
     */
    public  function returnApi($code, $msg, $type = false, $data = null)
    {
        $result = ['code' => $code, 'msg'  => $msg];
        if ($type) $result['content'] = $data;
        return $result;
    }

    /**
     * 处理分页数据，返回必要字段即可
     */
    public function disPageData($data){
        $datas = [];
        $datas['data'] = $data['data'];
        $datas['total'] = $data['total'];
        $datas['per_page'] = $data['per_page'];
        $datas['current_page'] = $data['current_page'];
        $datas['last_page'] = $data['last_page'];
        return $datas;
    }


    



}
